﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Http;
using System.Net.Http.Headers;
using XclusiveClient.Classes;

namespace XclusiveClient.XLOrder
{
    public partial class DeleteOrder : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnDel_Click(object sender, EventArgs e)
        {
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("http://localhost:3676/");

            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));

            HttpResponseMessage response = client.DeleteAsync("api/Order/" + tbxOrderID.Text).Result;
            if (response.IsSuccessStatusCode)
            {
                Response.Redirect("DeleteOrderSuccess.aspx");
            }
            else
            {
                lblResult.Text = "Unable to delete order. Error code: " + response.StatusCode + ", Reason: " + response.ReasonPhrase.ToString() + "<br/>";
            }
        }
    }
}